package com.ayuku.commons;

import com.ayuku.retail.persistence.model.AppGroup;
import com.ayuku.retail.persistence.model.Category;
import com.ayuku.retail.persistence.model.Customer;
import com.ayuku.retail.persistence.model.Purchase;
import com.ayuku.retail.persistence.model.Stock;
import com.ayuku.retail.persistence.model.Supplier;

/**
 * 
 * @author putu kusuma <putukn@gmail.com>
 *
 */
public class UtilPojo {
	
	
	public static void setDateAndUser(AppGroup pjo) throws Exception {
		pjo.setModifiedBy(Util.getCurrentUser().getUname());
		if (pjo.getCreatedBy() == null) {
			pjo.setCreatedBy(Util.getCurrentUser().getUname());
		}
		pjo.setModifiedDate(Util.getCurrentDate());
		if (pjo.getCreatedDate() == null) {
			pjo.setCreatedDate(Util.getCurrentDate());
		}
	}
	
	public static void setDateAndUser(Category pjo) throws Exception {
		pjo.setModifiedBy(Util.getCurrentUser().getUname());
		if (pjo.getCreatedBy() == null) {
			pjo.setCreatedBy(Util.getCurrentUser().getUname());
		}
		pjo.setModifiedDate(Util.getCurrentDate());
		if (pjo.getCreatedDate() == null) {
			pjo.setCreatedDate(Util.getCurrentDate());
		}
	}
	
	public static void setDateAndUser(Purchase pjo){
		pjo.setModifiedBy(Util.getCurrentUser().getUname());
		if (pjo.getCreatedBy() == null) {
			pjo.setCreatedBy(Util.getCurrentUser().getUname());
		}
		pjo.setModifiedDate(Util.getCurrentDate());
		if (pjo.getCreatedDate() == null) {
			pjo.setCreatedDate(Util.getCurrentDate());
		}
	}
	
	public static void setDateAndUser(Supplier pjo) throws Exception {
		pjo.setModifiedBy(Util.getCurrentUser().getUname());
		if (pjo.getCreatedBy() == null) {
			pjo.setCreatedBy(Util.getCurrentUser().getUname());
		}
		pjo.setModifiedDate(Util.getCurrentDate());
		if (pjo.getCreatedDate() == null) {
			pjo.setCreatedDate(Util.getCurrentDate());
		}
	}
	
	public static void setDateAndUser(Stock pjo) throws Exception {
		pjo.setModifiedBy(Util.getCurrentUser().getUname());
		if (pjo.getCreatedBy() == null) {
			pjo.setCreatedBy(Util.getCurrentUser().getUname());
		}
		pjo.setModifiedDate(Util.getCurrentDate());
		if (pjo.getCreatedDate() == null) {
			pjo.setCreatedDate(Util.getCurrentDate());
		}
	}

	public static void setDateAndUser(Customer pjo) throws Exception {
		pjo.setModifiedBy(Util.getCurrentUser().getUname());
		if (pjo.getCreatedBy() == null) {
			pjo.setCreatedBy(Util.getCurrentUser().getUname());
		}
		pjo.setModifiedDate(Util.getCurrentDate());
		if (pjo.getCreatedDate() == null) {
			pjo.setCreatedDate(Util.getCurrentDate());
		}
	}
	
	
}
